import React from "react";
import { View, Text, TouchableOpacity, StyleSheet } from "react-native";
import { useTranslation } from "react-i18next";

export const LangSetting = () => {
  const { t, i18n } = useTranslation();

  const changeLanguage = (lng: string) => {
    i18n.changeLanguage(lng);
  };

  return (
    <View style={styles.container}>
      <Text style={styles.title}>{t("language")}</Text>
      <View style={styles.languageButtons}>
        <TouchableOpacity
          style={styles.button}
          onPress={() => changeLanguage("zh")}
        >
          <Text>中文</Text>
        </TouchableOpacity>
        <TouchableOpacity
          style={styles.button}
          onPress={() => changeLanguage("en")}
        >
          <Text>English</Text>
        </TouchableOpacity>
      </View>
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    padding: 20,
  },
  title: {
    fontSize: 18,
    marginBottom: 10,
  },
  languageButtons: {
    flexDirection: "row",
    gap: 10,
  },
  button: {
    padding: 10,
    backgroundColor: "#eee",
    borderRadius: 5,
  },
});

export default LangSetting;
